//栈容器
#include <iostream>
using namespace std;
template<class DataType>
class stack{
public:
    DataType* data;//数据域
    int size;//栈的实际大小
    int top;//栈顶指针
    //栈的初始化
    stack(int sz){
        this->data=new DataType[sz];
        this->top=0;
        this->size=sz;
    }
    //判空函数
    bool isempty(){return this->top==0;}
    //判满函数
    bool isfull(){return this->top==this->size;}
    //入栈函数
    void push(const DataType& num){
        if(!this->isfull()){
            this->data[this->top++]=num;
            cout<<num<<"--入栈成功"<<endl;
        }
        else cout<<"栈满不能入栈"<<endl;
    }
    //出栈函数
    void pop(DataType& num){
        if(!this->isempty()){
            num=this->data[--(this->top)];
            cout<<num<<"--出栈成功"<<endl;
        }
    }
    //栈的销毁
    ~stack(){
        delete this->data;
        this->data=NULL;
    }
};
int main()
{
    string n="";
    stack<string> st(10);
    st.push("张三");
    st.pop(n);
    return 0;
}